from flask import jsonify, g

from app.auth import permission_required
from app.libs.redprint import RedPrint

api = RedPrint('constant')

USER_LIST = [
        'yfy@sntec.org.cn',
        'huangping@integritytech.com.cn',
        '企业定制版',
        'haiway@qq.com',
        'jiangxisc@yeah.net',
        '13500010822@139.com',
        'cdstm_siteman@cstm.org.cn',
        'pengccmail@qq.com',
        'jenny_good@163.com',
        'huangliang@cert.org.cn',
        'wangchao@chanct.com',
        'cpcpyssa@gmail.com',
        'security@citictrust.com.cn',
        'lw939109@gmail.com',
        'zxbsec@126.com',
        '234498170@qq.com',
        '554303724@qq.com',
        'ts@knownsec.com',
        'wanghj@knownsec.com',
        'wuh3@knownsec.com',
        'xiexq2@knownsec.com',
        'leijc@knownsec.com',
        'pengkc@knownsec.com',
        'liangzr@knownsec.com',
        'lij23@knownsec.com',
        'chenll@knownsec.com',
        'zhongjl@knownsec.com',
        'fan10-25@qq.com',
        '17734347650',
        ]


@api.route('/combo/get', methods=['GET'])
@permission_required('admin')
def combo_list():
    results = {
        "domain": {
            "label": "域名数",
            "limitType": "limit"
        },
        "domainEnable": {
            "label": "域名启用数",
            "limitType": "limit"
        },
        "contentManualTask": {
            "label": "内容监测单次任务次数",
            "limitType": "period",
            "time": 2629800000
        },
        "sslManualTask": {
            "label": "SSL监测单次任务次数",
            "limitType": "period",
            "time": 2629800000
        },
        "securityEventManualTask": {
            "label": "安全事件监测单次任务次数",
            "limitType": "period",
            "time": 2629800000
        },
        "assetManualTask": {
            "label": "资产变动监测单次任务次数",
            "limitType": "period",
            "time": 2629800000
        },
        "contentMaxPage": {
            "label": "内容监测最大URL数",
            "limitType": "frequency",
            "time": 2629800000
        },
        "maxPage": {
            "label": "最大URL数",
            "limitType": "max",
        },
        "securityEventMaxPage": {
            "label": "安全事件监测最大URL数",
            "limitType": "frequency",
            "time": 2629800000
        },
        "vulMaxPage": {
            "label": "漏洞监测最大URL数",
            "limitType": "frequency",
            "time": 2629800000
        },
        "contentMaxFreq": {
            "label": "内容监测最高频率",
            "limitType": "frequency",
            "time": 2629800000
        },
        "contentMaxDepth": {
            "label": "内容监测最大深度",
            "limitType": "frequency",
            "time": 2629800000
        },
        "vulMaxDepth": {
            "label": "漏洞监测最大深度",
            "limitType": "frequency",
            "time": 2629800000
        },
        "securityEventMaxDepth": {
            "label": "安全事件监测最大深度",
            "limitType": "frequency",
            "time": 2629800000
        },
        "httpMaxFreq": {
            "label": "HTTP监测最高频率",
            "limitType": "frequency",
            "time": 60000
        },
        "pingMaxFreq": {
            "label": "PING监测最高频率",
            "limitType": "frequency",
            "time": 60000
        },
        "vulManualTask": {
            "label": "漏洞监测单次任务数",
            "limitType": "period",
            "time": 604800000
        },
        "vulMaxFreq": {
            "label": "漏洞监测最高频率",
            "limitType": "frequency",
            "time": 604800000
        },
        "securityEventMaxFreq": {
            "label": "安全事件监测最高频率",
            "limitType": "frequency",
            "time": 86400000
        },
        "sslMaxFreq": {
            "label": "SSL监测最高频率",
            "limitType": "frequency",
            "time": 86400000
        },
        "assetMaxFreq": {
            "label": "资产变动监测最高频率",
            "limitType": "frequency",
            "time": 86400000
        },
        "httpMaxTask": {
            "label": "HTTP任务数",
            "limitType": "limit"
        },
        "httpMaxTaskEnable": {
            "label": "HTTP任务启用数",
            "limitType": "limit"
        },
        "pingMaxTask": {
            "label": "PING任务数",
            "limitType": "limit"
        },
        "pingMaxTaskEnable": {
            "label": "PING任务启用数",
            "limitType": "limit"
        },
        "httpMaxNode": {
            "label": "http监测节点数",
            "limitType": "frequency"
        },
        "pingMaxNode": {
            "label": "http监测节点数",
            "limitType": "frequency"
        },
        "whitelist": {
            "label": "白名单数",
            "limitType": "limit"
        },
        "smsAlert": {
            "label": "短信告警",
            "limitType": "period",
            "time": 2629800000
        },
        "emailAlert": {
            "label": "邮件告警数",
            "limitType": "period",
            "time": 2629800000
        },
        "alertGroup": {
            "label": "告警组",
            "limitType": "limit"
        },
        "alertReceiver": {
            "label": "告警人",
            "limitType": "limit"
        },
        "aviliableMaxHistory": {
            "label": "可用性历史数据",
            "limitType": "duration",
            "time": 86400000
        },
        "maxHistory": {
            "label": "安全历史数据",
            "limitType": "duration",
            "time": 86400000
        },
        "sitePortrait": {
            "label": "网站画像服务",
            "limitType": "limit"
        },
        "urlBLSMaxNum": {
            "label": "url加黑策略数",
            "limitType": "limit"
        },
        "hostVulManualTask": {
            "label": "主机监测单次任务数",
            "limitType": "period",
            "time": 604800000
        },
        "hostVulMaxFreq": {
            "label": "主机监测最高频率",
            "limitType": "frequency",
            "time": 604800000
        },
        "host": {
            "label": "主机资产数",
            "limitType": "limit"
        },
        "changeCheckMaxFreq": {
            "label": "篡改监测最高频率",
            "limitType": "frequency",
            "time": 86400000
        },
        "changeCheckMaxDepth": {
            "label": "篡改监测最大深度",
            "limitType": "frequency",
            "time": 2629800000
        },
        "changeCheckMaxPage": {
            "label": "篡改监测最大URL数",
            "limitType": "frequency",
            "time": 2629800000
        },
        "changeCheckMaxBaseChange": {
            "label": "篡改样本变更最高频率",
            "limitType": "frequency",
            "time": 2629800000
        },
        "changeCheckMaxKeyword": {
            "label": "篡改监测自定义关键词数量",
            "limitType": "frequency",
            "time": 86400000
        },
        "changeCheckMaxResource": {
            "label": "篡改监测重点关注资源数量",
            "limitType": "frequency",
            "time": 86400000
        },
    }

    return jsonify({'code': 200, 'msg': 'ok', 'results': results})


@api.route('/users/get', methods=['GET'])
def get_user_list():
    switch = False
    if g.user.username in USER_LIST:
        switch = True

    return jsonify({'code': 200, 'msg': 'ok', 'results': {'switch': switch}})

